/**
 *
 */
package com.aionengine.gameserver.model.gameobjects.siege;

import com.aionengine.gameserver.controllers.NpcController;
import com.aionengine.gameserver.model.gameobjects.Creature;
import com.aionengine.gameserver.model.gameobjects.Npc;
import com.aionengine.gameserver.model.siege.SiegeRace;
import com.aionengine.gameserver.model.templates.npc.NpcTemplate;
import com.aionengine.gameserver.model.templates.spawns.siegespawns.SiegeSpawnTemplate;

/**
 * @author ViAl
 */
public class SiegeNpc extends Npc {

    private int siegeId;
    private SiegeRace siegeRace;

    /**
     * @param objId
     * @param controller
     * @param spawnTemplate
     * @param objectTemplate SiegeNpc constructor
     */
    public SiegeNpc(int objId, NpcController controller, SiegeSpawnTemplate spawnTemplate, NpcTemplate objectTemplate) {
        super(objId, controller, spawnTemplate, objectTemplate);
        this.siegeId = spawnTemplate.getSiegeId();
        this.siegeRace = spawnTemplate.getSiegeRace();
    }

    public SiegeRace getSiegeRace() {
        return siegeRace;
    }

    public int getSiegeId() {
        return siegeId;
    }

    @Override
    public SiegeSpawnTemplate getSpawn() {
        return (SiegeSpawnTemplate) super.getSpawn();
    }

    /**
     * Siege Npcs of different SiegeRaces are always hostile
     */
    @Override
    public boolean isEnemyFrom(Creature creature) {
        if (creature instanceof SiegeNpc && this.getSiegeRace() != ((SiegeNpc) creature).getSiegeRace()) {
            return true;
        } else
            return super.isEnemyFrom(creature);
    }


}
